package cn.edu.wynu.jdbc;

import java.sql.*;

public class MyFirstJdbcLearn {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "123456");
        Statement statement = connection.createStatement();

        String sql = "select * from student";
        ResultSet resultSet = statement.executeQuery(sql);

        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            String sex = resultSet.getString("sex");
            System.out.println(id + name + sex);
        }

        statement.close();
        connection.close();
    }
}
